/*
 * @Author: giky
 * @Date: 2018-12-05 09:00:35
 * @Last Modified by: giky
 * @Last Modified time: 2018-12-05 11:15:59
 */

//一般直接写在一个js文件中
layui
  .config({
    base: "../../layuiadmin/" //静态资源所在路径
  })
  .extend({
    setter: "config", //配置模块
    admin: "lib/admin", //核心模块
    view: "lib/view", //视图渲染模块
    exts: "modules/exts" //主入口模块
  })
  .define(["form", "setter", "admin", "exts"], function(exports) {
    var setter = layui.setter,
      admin = layui.admin,
      form = layui.form,
      events = layui.admin.events,
      $ = layui.$,
      mapObj = {},
      view = layui.view;

    layer.msg("Hello World");

    layui.zkMap = {};

    layui.zkMap.popupLeft = function(options) {
      //layer.close(admin.popup.index);
      // console.log(222,options)
      return (admin.popup.index = layer.open(
        $.extend(
          {
            type: 1,
            id: "LAY_adminPopupL",
            offset: ["0px", "316px"],
            move: false,
            shade: 0.1,
            anim: -1,
            shadeClose: true,
            title: false,
            closeBtn: false,
            skin: "layui-anim layui-anim-zy",
            area: ["300px", "100%"]
          },
          options
        )
      ));
    };

    var extEvents = {
      wifi: function() {
        var btnName = $(this)
          .find("p")
          .text();
        admin.popupLeft({
          id: "LAY_adminPopupLeft",
          title: btnName,
          // ,shade: 0
          // ,closeBtn: true
          // ,area:  ['500px','100%']
          // ,skin:'layui-layer-lan'
          success: function() {
            view(this.id).render("system/wifi");
          }
        });
      },
      camera: function() {
        var btnName = $(this)
          .find("p")
          .text();
        admin.popupLeft({
          id: "LAY_adminPopupLeft2",
          title: btnName,
          success: function() {
            view(this.id).render("system/theme");
          }
        });
      }
    };

    layui.zkMap.events = $.extend(events, extEvents);

    console.log(layui);
    // form.render();
    exports("demo", extEvents);
  });
